package com.dede.applib.extends

import android.text.SpannableString
import android.text.style.AbsoluteSizeSpan
import android.text.style.ForegroundColorSpan

/**
 * @author hsh
 * @time 2017/9/22 022 11:40 下午.
 * @doc
 */

fun SpannableString.size(fontSize: Int, start: Int = 0, end: Int = this.length,
                         flags: Int = SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE): SpannableString {
    val span = AbsoluteSizeSpan(fontSize)
    setSpan(span, start, end, flags)
    return this
}

fun SpannableString.color(color: Int, start: Int = 0, end: Int = this.length,
                          flags: Int = SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE): SpannableString {
    val colorSpan = ForegroundColorSpan(color)
    setSpan(colorSpan, start, end, flags)
    return this
}